package com.king.springcloud.service.impl;

import com.king.springcloud.dao.AccountDao;
import com.king.springcloud.domain.CommonResult;
import com.king.springcloud.service.AccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author king
 * @date 2020/10/20 23:49
 */
@Service
public class AccountServiceImpl implements AccountService {
    @Resource
    private AccountDao accountDao;

    @Override
    public CommonResult decrease(Long userId, Integer money) {
        accountDao.decrease(userId, money);
        // 模拟订单异常
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return new CommonResult(200, "扣款成功");
    }
}
